import { GETBANNERLIST,DELETEBANNER } from "./constant"
import bannerState from "./state"

function bannerReducer(state = bannerState, action) {
  const {type,data} = action
  switch (type) {
    case GETBANNERLIST:
      return {
        ...state,
        // 拼接数组
        bannerList:  [...state.bannerList, ...data]
      }
    case DELETEBANNER:
      return {
        ...state,
        bannerList: state.bannerList.filter(item => item.objectId !== data.objectId)
      }
    default:
      return state
  }
}

export default bannerReducer